const util = require('../../utils/util');

Page({
    data: {
        isLoading: false,
        isDisabled: true,
        realName: '',
        mobile: '',
        idCardNum: '',
        birthday: '',
        region: '',
        password: '',
        rePassword: ''
    },
    onLoad: function () {
        wx.setNavigationBarTitle({
            title: '注册'
        })
    },
    bindRegionChange: function (e) {
        var ragionArr = e.detail.value;
        var ragionStr = ragionArr[0];
        if (ragionArr[1] == '县' || ragionArr[1] == ragionArr[0]) {
            //ragionStr += ' ' + ragionArr[2];
        } else {
            ragionStr += ' ' + ragionArr[1];
            //ragionStr += ' ' + ragionArr[2];
        }
        if (ragionStr.length > 10) {
            ragionStr = ragionStr.substring(0, 11) + "..";
        }
        this.setData({
            region: ragionStr
        });

    },
    bindDateChange: function (e) {
        this.setData({
            birthday: e.detail.value
        })
    },
    bindRealNameChange: function (e) {
        this.setData({
            realName: e.detail.value
        })
        this.canButtonUse();
    },
    bindMobileChange: function (e) {
        this.setData({
            mobile: e.detail.value
        })
        this.canButtonUse();
    },
    bindIdcardNumChange: function (e) {
        this.setData({
            idCardNum: e.detail.value
        })
    },
    bindPasswordChange: function (e) {
        this.setData({
            password: e.detail.value
        })
        this.canButtonUse();
    },
    bindRePasswordChange: function (e) {
        this.setData({
            rePassword: e.detail.value
        })
        this.canButtonUse();
    },
    canButtonUse: function () {
        if(this.data.realName=='' || this.data.mobile=='' || this.data.password=='' || this.data.rePassword==''){
            this.setData({
                isDisabled: true
            })
        }else{
            this.setData({
                isDisabled: false
            })
        }
    },
    doRegist:function (e) {
        this.setData({
            isLoading: true,
            isDisabled: true
        })

    }
})